/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <js_native_api.h>
#include <js_native_api_types.h>
#include <napi/native_common.h>
#include <napi/native_api.h>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <string>
#include "<key_word>_def.h"
#include "<key_word>_srv_client.h"
#include "hilog_wrapper.h"
#include "<key_word>_utils.h"
#include "<key_word>_napi.h"

namespace <namespace> {
namespace <Subsys_name> {

thread_local static <Key_word>SrvClient& g_<key_word>Client = <Key_word>SrvClient::GetInstance();

/**
 * @brief 定义接口函数
 * static napi_value XXXX(napi_env env, napi_callback_info info)
 * @param env 
 * @param info 
 * @return napi_value 
 */
<define_api>

/**
 * @brief 定义枚举类型
 */
static napi_value EnumClassConstructor(napi_env env, napi_callback_info info)
{
    napi_value thisArg = nullptr;
    void* data = nullptr;

    napi_get_cb_info(env, info, nullptr, nullptr, &thisArg, &data);

    napi_value global = nullptr;
    napi_get_global(env, &global);

    return thisArg;
}

<define_enum>
EXTERN_C_START
/*
 * function for module exports
 */
static napi_value <Key_word>Init(napi_env env, napi_value exports)
{
    <KEY_WORD>_HILOGD(<KEY_WORD>_JS_NAPI, "Enter");

    napi_property_descriptor desc[] = {
    <declare_getter>
    };
    NAPI_CALL(env, napi_define_properties(env, exports,<method_count>, desc));
    
    <create_enum>

    <KEY_WORD>_HILOGD(<KEY_WORD>_JS_NAPI, "Success");

    return exports;
}
EXTERN_C_END

/*
 * Module definition
 */
static napi_module g_module = {
    .nm_version = 1,
    .nm_flags = 0,
    .nm_filename = nullptr,
    .nm_register_func = <Key_word>Init,
    .nm_modname = "<key_word>",
    .nm_priv = ((void*)0),
    .reserved = {0}
};
/*
 * Module registration
 */
extern "C" __attribute__((constructor)) void RegisterModule(void)
{
    napi_module_register(&g_module);
}

}  // namespace <Subsys_name>
}  // namespace <namespace>
